package com.fenghuajueli.libbasecoreui.dialogfragment;

import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.TextView;

import com.fenghuajueli.libbasecoreui.R;
import com.ijianji.lsx_ui_lib.BaseDialogFragment;

public class MessageDialogFragment extends BaseDialogFragment {

    String content;

    @Override
    public int getLayoutRes() {
        return R.layout.dialog_fragment_message;
    }

    @Override
    public void initView(Context context, View view, AttributeSet attributeSet) {
        TextView tvContext = view.findViewById(R.id.tv_content);
        tvContext.setText(content);
        view.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onLeftClick();
                }
                dismiss();
            }
        });
        view.findViewById(R.id.tv_determine).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (listener != null) {
                    listener.onRightClick();
                }
                dismiss();
            }
        });
    }

    @Override
    public void initData(Context context) {

    }

    @Override
    public void initEvent(Context context) {

    }

    @Override
    public int getGravity() {
        return Gravity.CENTER;
    }

    public void setMessageContent(String content){
        this.content= content;
    }

    public interface MessageDialogListener {
        void onRightClick();
        void onLeftClick();
    }

    MessageDialogListener listener;

    public void setMessageDialogListener(MessageDialogListener listener){
        this.listener = listener;
    }
}
